//
//  InsadeViewController.m
//  MenkNav
//
//  Created by Burn on 2019/6/13.
//  Copyright © 2019 menksoft. All rights reserved.
//

#import "InsadeViewController.h"
#import "RemoteView.h"
@interface InsadeViewController ()<UITableViewDelegate, UITableViewDataSource>

@property(strong,nonatomic) UITableView *tableView;




@end

static NSString *ID = @"ID";
@implementation InsadeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    //  http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4
    //  http://mirror.aarnet.edu.au/pub/TED-talks/911Mothers_2010W-480p.mp4
    //  http://mgl.nmtv.cn//Portals/_MenkCms/Medias/2019/04/30/15259_1243224214.mp4
    CGRect frame = CGRectMake(0, SafeAreaLiuHiaHeight, SCREEN_WIDTH, SCREEN_WIDTH * 9 / 16);
    RemoteView *rview = [[RemoteView alloc]initWith:[NSURL URLWithString:@"http://mgl.nmtv.cn//Portals/_MenkCms/Medias/2019/04/30/15259_1243224214.mp4"] cachePolicy:NO frame:frame];
    [self.view addSubview:rview];
    
    self.playerVC = YES;
    self.playerView = rview;
    
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(fullScreenClick:) name:FULLSCREENCLICK object:nil];
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(backClick) name:PLAYBACK object:nil];
    
    [self.view addSubview:self.tableView];
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:ID];
}

- (void)fullScreenClick:(NSNotification *)notification{
    [self fullScreenAction];
}

- (void)backClick{
    if (self.isFullScreen) {
        [self fullScreenAction];
    }else{
        [self.navigationController popViewControllerAnimated:YES];
    }
}

- (CGFloat)mk_navigationHeight:(MenkNavnigationBar *)navigationBar{
    return 0;
}

-(void)dealloc{
    DLOG(@"InsadeViewController - dealloc");
    [[NSNotificationCenter defaultCenter]removeObserver:self];
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 20;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
    }
    cell.textLabel.text = [NSString stringWithFormat:@"%ld",indexPath.row];
    return cell;
}

- (UITableView *)tableView{
    if (!_tableView) {
        CGRect frame = CGRectMake(0,SCREEN_WIDTH * 9 / 16 + 15, SCREEN_WIDTH, SCREEN_HEIGHT - SCREEN_WIDTH * 9 / 16);
        _tableView = [[UITableView alloc]initWithFrame:frame style:UITableViewStylePlain];
        _tableView.delegate = self;
        _tableView.dataSource = self;
    }
    return _tableView;
}


@end
